import numpy as np
import matplotlib.pyplot as plt
from matplotlib.path import Path
import matplotlib.patches as patches

# 创建一个新的图形
fig, ax = plt.subplots()

# 定义五角星的顶点
verts = [
    (0.6, 0.30),
    (0.87, 0.05),
    (1.0, 0.7),
    (0.5, 0.8),
    (0.1, 0.4),
    (0.3, 0.1),
    (0.6, 0.30)
]

# 创建一个五角星的路径
codes = [Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.CLOSEPOLY]
path = Path(verts, codes)

# 创建一个五角星的补丁
patch = patches.PathPatch(path, facecolor='black', lw=0)

# 将五角星补丁添加到轴上
ax.add_patch(patch)

# 设置轴的限制
ax.set_xlim(-0.2, 1.2)
ax.set_ylim(-0.2, 1.2)

# 隐藏轴
ax.axis('off')

# 保存五角星蒙版图像
plt.savefig('star_mask.png', bbox_inches='tight', pad_inches=0)
plt.show()